
/****** Object:  Table [dbo].[Features]    Script Date: 03/14/2013 16:53:29 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Features](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Type] [varchar](255) NOT NULL,
	[IsEnabled] [bit] NOT NULL,
 CONSTRAINT [PK_Features] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

CREATE PROCEDURE [dbo].[LoadFeatures]

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT Type, IsEnabled from Features
END

GO

CREATE PROCEDURE [dbo].[InsertOrUpdateFeatures]
	@fullTypeName varchar(255),
	@isEnabled bit	
AS
BEGIN
   SET NOCOUNT ON;

   begin tran
   update Features with (serializable) set IsEnabled = @isEnabled 
   where Type=@fullTypeName

   if @@rowcount = 0
   begin
      insert Features (Type,IsEnabled) values (@fullTypeName, @isEnabled)
   end
commit tran
END

GO


